/**
 * 
 */
package fr.upmc.alasca.centreCalcul.interne.machinePhysique.machineVirtuelle.ports;

import fr.upmc.alasca.centreCalcul.interne.machinePhysique.machineVirtuelle.MachineVirtuelle;
import fr.upmc.alasca.centreCalcul.interne.machinePhysique.machineVirtuelle.interfaces.MachineVirtuelleCoeurI;
import fr.upmc.alasca.centreCalcul.objets.Requete;
import fr.upmc.components.ComponentI;
import fr.upmc.components.ComponentI.ComponentService;
import fr.upmc.components.ports.AbstractInboundPort;

/**
 * @author Slimm
 *
 */
public class MachineVirtuelleCoeurInboundPort 
extends		AbstractInboundPort
implements MachineVirtuelleCoeurI{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public MachineVirtuelleCoeurInboundPort(
			String uri,
			ComponentI owner
			) throws Exception
	{
		super(uri, MachineVirtuelleCoeurI.class, owner);
	}

	@Override
	public void finExecutionRequete(final String uriCoeur, final Requete requete,
			final long tempsExecution, final boolean coeurDisponible) throws Exception {
		final MachineVirtuelle mv = (MachineVirtuelle)this.owner;
		mv.handleRequestAsync(
				new ComponentService<Void>() {
					@Override
					public Void call() throws Exception{
						mv.finExecutionRequete(uriCoeur, requete, tempsExecution, coeurDisponible);
						return null;
					}
				});
		
	}

	@Override
	public void attributionNouveauCoeur(String uriCoeur) throws Exception {
		((MachineVirtuelle)this.owner).attributionNouveauCoeur(uriCoeur);
	}

	@Override
	public void retraitCoeur(String uriCoeur) throws Exception {
		((MachineVirtuelle)this.owner).retraitCoeur(uriCoeur);
	}
	
	

}
